package com.sgb.kjwl.view.ui.adapter.self.bid;

import android.content.Context;
import android.graphics.Color;
import android.text.TextUtils;
import android.widget.TextView;

import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.BidEntity;
import com.sgb.kjwl.view.ui.activity.pick.QuoteImmediatelyActivity;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;

import java.util.List;

public class BidGcAdapter extends BaseRecycleAdapter<BidEntity> {
    private TextView mTvQuotedPrice;
    public BidGcAdapter(Context context, List<BidEntity> datas) {
        super(context, R.layout.item_bid_gc, datas);
    }

    @Override
    public void convert(ItemViewHolder holder, final BidEntity entity) {
        holder.setBinding(BR.viewModel, entity);
        mTvQuotedPrice = holder.itemView.findViewById(R.id.tv_quoted_price);
        mTvQuotedPrice.setOnClickListener(view -> {
            QuoteImmediatelyActivity.startAgain(context, entity, R.layout.item_bid_gc);
        });

        if (TextUtils.isEmpty(entity.getProjectStatus()) || entity.getProjectStatus().equals("0")) {
            mTvQuotedPrice.setClickable(true);
            mTvQuotedPrice.setTextColor(context.getResources().getColor(R.color.button_blue));
            mTvQuotedPrice.setText("再次报价");
            mTvQuotedPrice.setBackgroundResource(R.drawable.square_blue_bg);
        } else {
            mTvQuotedPrice.setClickable(false);
            mTvQuotedPrice.setTextColor(Color.GRAY);
            mTvQuotedPrice.setText("项目结束");
            mTvQuotedPrice.setBackgroundResource(R.drawable.square_gray_bg);
        }
    }
}
